[PATCH] h2645parser: Catch overflows in AVC/HEVC NAL unit length calculations
authorSebastian Dröge <sebastian@centricular.com>
Tue, 23 Mar 2021 17:19:14 +0000 (19:19 +0200)
committerLaurent Bigonville <bigon@debian.org>
Mon, 26 Apr 2021 15:07:50 +0000 (16:07 +0100)
commitaee482f87bac5291925ae7c187955bdfe7ff1942
tree966f217fd2bc21065ea321a35080e907d5ee0b6b
parent27f2ee03f2f16c38eb1b84c98f2e8e4996788707
[PATCH] h2645parser: Catch overflows in AVC/HEVC NAL unit length calculations

Offset and size are stored as 32 bit guint and might overflow when
adding the nal_length_size, so let's avoid that.

For the size this would happen if the AVC/HEVC NAL unit size happens to
be stored in 4 bytes and is 4294967292 or higher, which is likely
corrupted data anyway.

For the offset this is something for the caller of these functions to
take care of but is unlikely to happen as it would require parsing on a
>4GB buffer.

Allowing these overflows causes all kinds of follow-up bugs in the
h2645parse elements, ranging from infinite loops and memory leaks to
potential memory corruptions.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2103>

Gbp-Pq: Name 0001-h2645parser-Catch-overflows-in-AVC-HEVC-NAL-unit-length.patch
gst-libs/gst/codecparsers/gsth264parser.c
gst-libs/gst/codecparsers/gsth265parser.c
tests/check/libs/h264parser.c
tests/check/libs/h265parser.c